package cn.tedu.cinema.scheduling.controller;

import cn.tedu.cinema.base.response.JsonResult;
import cn.tedu.cinema.scheduling.pojo.dto.SchedulingQuery;
import cn.tedu.cinema.scheduling.pojo.dto.SchedulingSaveParam;
import cn.tedu.cinema.scheduling.pojo.vo.SchedulingVO;
import cn.tedu.cinema.scheduling.service.SchedulingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/scheduling")
@Slf4j
public class SchedulingController {
    @Autowired
    private SchedulingService schedulingService;
    @PostMapping("/save")
    public JsonResult schedulingSave(SchedulingSaveParam schedulingSaveParam) {
        log.debug("排片参数:{}", schedulingSaveParam);
        schedulingService.save(schedulingSaveParam);
        return JsonResult.ok();
    }
    @GetMapping("/select")
    public JsonResult selectScheduling(SchedulingQuery schedulingQuery) {
        log.debug("查询排片,参数={}", schedulingQuery);
        List<SchedulingVO> list = schedulingService.selectScheduling(schedulingQuery);
        log.debug("查询结果:{}", list);
        return JsonResult.ok(list);
    }

    @GetMapping("/selectshijian")
    public JsonResult selectScheduling1(SchedulingQuery schedulingQuery) {
        log.debug("查询排片,参数={}", schedulingQuery);
        List<SchedulingVO> list = schedulingService.selectScheduling1(schedulingQuery);
        log.debug("查询结果:{}", list);
        return JsonResult.ok(list);
    }

    @GetMapping("/selectById")
    public JsonResult selectById(Integer id) {
        log.debug("查询排片,参数={}", id);
        SchedulingVO schedulingVO = schedulingService.selectById(id);
        return JsonResult.ok(schedulingVO);
    }
    @DeleteMapping("/delete")
    public JsonResult deleteScheduling(Integer id) {
        log.debug("删除排片,参数={}", id);
        schedulingService.deleteScheduling(id);
        return JsonResult.ok();
    }
    @GetMapping("/selectByMovieId")
    public JsonResult selectByMovieId(SchedulingQuery schedulingQuery) {
        log.debug("查询排片详情,参数={}", schedulingQuery);
        List<SchedulingVO> list = schedulingService.selectByMovieId(schedulingQuery);
        return JsonResult.ok(list);
    }
}
